function parseBold (md) {
  let boldTag = [] 
  let data = md.innerHTML
  let charArr = data.split('')
  for (let i = 0; i < charArr.length; i++) {
    if (charArr[i] == '*') {
      boldTag.push(charArr[i])
      if (boldTag.length > 0 && boldTag.length %2 == 0) {
        if (boldTag.length < 4) {
          charArr.splice(i-1, 2, '<b>')
        } else {
          charArr.splice(i-1, 2, '</b>')
          for (let j = 0; j < 4; j++) {
            boldTag.pop()
          }
        }
      }
    }
  }
  if (charArr.lastIndexOf('</b>') < charArr.lastIndexOf('<b>')) {
    charArr.splice(charArr.lastIndexOf('<b>'), 1, '**')
  }
  md.innerHTML = charArr.join('')
}

export default parseBold
